package com.yootk.listener;

import jakarta.servlet.annotation.WebListener;
import jakarta.servlet.http.HttpSessionAttributeListener;
import jakarta.servlet.http.HttpSessionBindingEvent;

/**
 * Session属性操作监听
 */
@WebListener
public class SessionAttributeMonitor implements HttpSessionAttributeListener {

    @Override
    public void attributeAdded(HttpSessionBindingEvent se) {    // 属性增加时触发
        System.out.println("【SessionAttributeMonitor.attributeAdded()】属性增加，属性名称：" + se.getName() + "、属性内容：" + se.getValue());
    }

    @Override
    public void attributeRemoved(HttpSessionBindingEvent se) { // 属性删除时触发
        System.out.println("【SessionAttributeMonitor.attributeRemoved()】属性删除，属性名称：" + se.getName() + "、属性内容：" + se.getValue());
    }

    @Override
    public void attributeReplaced(HttpSessionBindingEvent se) { // 属性替换时触发
        System.out.println("【SessionAttributeMonitor.attributeReplaced()】属性替换，属性名称：" + se.getName() + "、属性内容：" + se.getValue());
    }
}
